Implement structured API error handling and enhance timeout management#8
Merged
voidcommit-afk merged 3 commits intomainfrom Mar 22, 2026
Merged
Implement structured API error handling and enhance timeout management#8voidcommit-afk merged 3 commits intomainfrom
voidcommit-afk merged 3 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improved handling of API error responses across both backend and frontend, with a focus on better error messaging, quota/rate limit awareness, and user experience. The backend now passes a
proflag to request control logic, ensuring that Pro users bypass quota checks. On the frontend, a new unified error parsing utility provides clearer feedback to users, especially around quota and rate limiting, and controls when retries are allowed.The most important changes are:
Backend: Pro User Handling and Quota Checks
Added an
is_proflag to theenforce_request_controlsfunction and its callers, ensuring that Pro users are exempt from daily quota checks. This affects both chat message and topic query endpoints. [1] [2] [3] [4] [5] [6]Improved streaming response handling to ensure that partial responses and errors are properly cached and labeled, and that users are informed when a connection is interrupted, with messaging tailored to the selected mode (e.g., "technical" or "socratic"). [1] [2]
Frontend: Unified API Error Handling and Messaging
Introduced a new
buildApiErrorutility insrc/lib/httpErrors.tsto standardize error parsing and messaging for API responses, including quota and rate limit errors. [1] [2] [3] [4]Updated all API request functions (
fetchAPI,queryTopic,queryTopicStream, and chat service) to use the new error utility, providing more detailed and user-friendly error messages and controlling retry logic based on error detail (e.g., not retrying on quota exceeded). [1] [2] [3] [4] [5] [6] [7]API Improvements
These changes result in a more robust user experience, clearer error feedback, and improved handling of Pro user privileges and quota enforcement.